﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MyManagement.Model
{
    /// <summary>
    /// Describes a product.
    /// </summary>
    public class Product
    {
        private List<Iteration> iterations;
        private List<UserStory> stories;

        /// <summary>
        /// Initializes a new instance of the <see cref="Product" /> class.
        /// </summary>
        public Product()
        {
            this.iterations = new List<Iteration>();
            this.stories = new List<UserStory>();
        }

        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>The title.</value>
        public string Title
        {
            get;
            set;
        }
        
        /// <summary>
        /// Gets or sets the owner.
        /// </summary>
        /// <value>The owner.</value>
        public Person Owner
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the manager.
        /// </summary>
        /// <value>The manager.</value>
        public Person Manager
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the user stories.
        /// </summary>
        /// <value>The user stories.</value>
        public IEnumerable<UserStory> UserStories
        {
            get;
            set;
        }

        /// <summary>
        /// Adds the story.
        /// </summary>
        /// <param name="value">The value.</param>
        public void AddStory(UserStory value)
        {
            // validate input

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            // add it

            this.stories.Add(value);
        }

        /// <summary>
        /// Adds the iteration.
        /// </summary>
        /// <param name="value">The value.</param>
        public void AddIteration(Iteration value)
        {
            // validate input

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            // add it

            this.iterations.Add(value);
        }
    }
}